//
//  TKL_CicleCell.m
//  TKL_EnPro
//
//  Created by 雅恩三河科技 on 2018/12/11.
//  Copyright © 2018年 MrZhang. All rights reserved.
//

#import "TKL_CicleCell.h"
#import "TKL_CircleBtomView.h"
@interface TKL_CicleCell ()
@property(nonatomic,strong)UILabel* titleLab;
@property(nonatomic,strong)UILabel* moreLab;
@property(nonatomic,strong)UILabel* autLab;
@property(nonatomic,strong)UILabel* timeLab;
@property(nonatomic,strong)UIImageView* markIV;
@property(nonatomic,strong)UIImageView* coverIV;
@property(nonatomic,strong)TKL_CircleBtomView* btomView;
@end

@implementation TKL_CicleCell
-(TKL_CircleBtomView *)btomView
{
    if (!_btomView) {
        _btomView=[[TKL_CircleBtomView alloc] init];
        _btomView.x=WFCGFloatX(20);
        _btomView.y=WFCGFloatY(290);
        _btomView.width=WFCGFloatX(335);
        _btomView.height=WFCGFloatY(30);
        _btomView.backgroundColor=[UIColor whiteColor];
    }
    return _btomView;
}
-(UILabel *)titleLab
{
    if (!_titleLab) {
        _titleLab=[UILabel new];
        _titleLab.x=WFCGFloatX(66);
        _titleLab.y=WFCGFloatY(15);
        _titleLab.width=WFCGFloatX(200);
        _titleLab.height=WFCGFloatY(35);
        _titleLab.textColor=YN_Light_Black_Color;
        _titleLab.font=SYSTEMFONT(16);
        
    }
    return _titleLab;
}
-(UILabel *)moreLab
{
    if (!_moreLab) {
        _moreLab=[UILabel new];
        _moreLab.y=WFCGFloatY(65);
        _moreLab.width=WFCGFloatX(335);
        _moreLab.textColor=YN_Gray_Color;
        _moreLab.height=WFCGFloatY(40);
        _moreLab.x=WFCGFloatX(20);
        _moreLab.font=SYSTEMFONT(14);
        _moreLab.numberOfLines=2;
        
    }
    return _moreLab;
}

-(UILabel *)autLab
{
    if (!_autLab) {
        _autLab=[UILabel new];
        _autLab.x=WFCGFloatX(26);
        _autLab.y=WFCGFloatY(105);
        _autLab.width=WFCGFloatX(130);
        _autLab.height=WFCGFloatY(12);
        _autLab.textColor=YN_Light_Gray_Color;
        _autLab.font=SYSTEMFONT(12);
        
    }
    return _autLab;
}
-(UILabel *)timeLab
{
    if (!_timeLab) {
        _timeLab=[UILabel new];
        
        _timeLab.y=WFCGFloatY(106);
        _timeLab.width=WFCGFloatX(70);
        _timeLab.textColor=YN_Light_Gray_Color;
        _timeLab.height=WFCGFloatY(12);
        _timeLab.x=WFCGFloatX(160);
        _timeLab.font=SYSTEMFONT(11);
    }
    return _timeLab;
}
-(UIImageView *)markIV
{
    if (!_markIV) {
        _markIV=[UIImageView new];
        _markIV.width=WFCGFloatX(35);
        _markIV.height=WFCGFloatY(35);
        _markIV.x=WFCGFloatX(20);
        _markIV.y=WFCGFloatY(15);
        [WFFunctions WFUIaddbordertoView:_markIV radius:WFCGFloatX(35/2) width:0 color:[UIColor clearColor]];
    }
    return _markIV;
}
-(UIImageView *)coverIV
{
    if (!_coverIV) {
        _coverIV=[UIImageView new];
        _coverIV.x=WFCGFloatX(20);
        _coverIV.y=WFCGFloatY(115);
        _coverIV.width=WFCGFloatX(335);
        _coverIV.height=WFCGFloatY(170);
        _coverIV.layer.masksToBounds=YES;
        _coverIV.contentMode=UIViewContentModeScaleAspectFill;
    }
    return _coverIV;
}
-(UIScrollView *)imageScroll
{
    if (!_imageScroll) {
        _imageScroll=[[UIScrollView alloc] init];
        _imageScroll.x=WFCGFloatX(20);
        _imageScroll.y=WFCGFloatY(115);
        _imageScroll.width=WFCGFloatX(335);
        _imageScroll.height=WFCGFloatY(110);
    }
    return _imageScroll;
}
#pragma mark - event
#pragma mark - method
#pragma mark - life
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = Main_Color_White;
        [self.contentView addSubview:self.titleLab];
        [self.contentView addSubview:self.moreLab];
        [self.contentView addSubview:self.markIV];
        [self.contentView addSubview:self.coverIV];
        [self.contentView addSubview:self.btomView];
    }
    return self;
}

-(void)setSourceDic:(NSMutableDictionary *)sourceDic
{
    [_btomView setDataSource:sourceDic];
    
//    self.btomView.y=self.height-WFCGFloatY(30);
    if (![WFFunctions WFStrCheckEmpty:[sourceDic objectForKey:@"author"]])
    {
        _titleLab.text=[WFFunctions WFCheckEmptyBackStr:[[sourceDic objectForKey:@"author"] objectForKey:@"nickname"]];
        [_markIV sd_setImageWithURL:[NSURL URLWithString:[WFFunctions WFCheckEmptyBackStr:[[sourceDic objectForKey:@"author"] objectForKey:@"avatar"]]] placeholderImage:DefaultAvatarMImage];
    }
    
    _moreLab.text=[WFFunctions WFCheckEmptyBackStr:[sourceDic objectForKey:@"title"]];
    [_coverIV sd_setImageWithURL:[NSURL URLWithString:[WFFunctions WFCheckEmptyBackStr:[sourceDic objectForKey:@"cover"]]] placeholderImage:DefaultImage];
    
//    [self.imageScroll removeAllSubviews];
//    if (![WFFunctions WFStrCheckEmpty:[sourceDic objectForKey:@"images"]])
//    {
//        NSArray* arr=[sourceDic objectForKey:@"images"];
//        NSInteger count=0;
//        if (arr.count>3)
//        {
//            count=3;
//        }else
//        {
//            count=arr.count;
//        }
//        float ww=(WFCGFloatX(335)-WFCGFloatY(110)*3)/2;
//        for (int i=0; i<count; i++)
//        {
//            UIImageView* hhIV=[UIImageView new];
//            hhIV.width=WFCGFloatY(110);
//            hhIV.height=WFCGFloatY(110);
//            hhIV.x=(WFCGFloatY(110)+ww)*i;
//            hhIV.y=WFCGFloatY(0);
//            [self.imageScroll addSubview:hhIV];
//            hhIV.contentMode=UIViewContentModeScaleAspectFill;
//            hhIV.layer.masksToBounds=YES;
//            [hhIV sd_setImageWithURL:[NSURL URLWithString:[arr[i] objectForKey:@"url"]] placeholderImage:DefaultImage];
//            
//            
//            __block UIImageView* pp=hhIV;
//            [hhIV addTapGestureRecognizerWithDelegate:self Block:^(NSInteger tag) {
//                
//                PYPhotoBrowseView *photoBroseView = [[PYPhotoBrowseView alloc] init];
//                photoBroseView.imagesURL = @[[arr[i] objectForKey:@"url"]];
//                photoBroseView.currentIndex = 0;
//                photoBroseView.sourceImgageViews=@[pp];
//                [photoBroseView show];
//            }];
//        }
//    }
}
@end
